/**
 * Copyright 厦门中软海晟信息技术有限公司 版权所有 违者必究 2019
 */
package com.zf.platform;

import com.zf.platform.entity.User;
import com.zf.platform.repository.UserRepository;
import com.zf.platform.support.util.Aes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;

/**
 * @author : sunzb(sunzb@hsit.com.cn)
 * @date: 2019/1/7
 */
@Service
public class InitService {

    @Autowired
    UserRepository userRepository;
    @Value("${project.aes}")
    String aesKey;

    @PostConstruct
    @Transactional
    public void init() {
        Aes.KEY = aesKey;
        User user = userRepository.save(new User()
            .setUsername("super_admin")
            .setPassword(Aes.aesEncrypt("111"))
            .setRole("super_admin"));
        System.out.println("user id : " + user.getId());
    }
}
